package com.mask.juc.v1.c_013_threadLocal;

import java.lang.ref.WeakReference;

/**
 * 弱引用
 * 弱引用遭到gc就会回收
 * 一般用在容器里，
 * @author hx
 * @date 2021/10/14 4:47 下午
 */

public class T03_WeakReference {
    public static void main(String[] args) {
        WeakReference<M> m = new WeakReference<>(new M());
        System.out.println(m.get());
        System.gc();
        System.out.println(m.get());

        ThreadLocal<M> t1 = new ThreadLocal<>();
        t1.set(new M());
        t1.remove();
    }
}
